<template>
  <div>
    <h1>基本信息</h1>
    ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
    <el-form :model="form" ref="form" label-width="100px" class="demo-ruleForm">
      <tr>
        <td>
          <el-form-item label="部门:">
            <el-select v-model="form.buMne" placeholder="请选择部门" clearable>
              <el-option v-for="item in options" :key="item.id" :label="item.buMenName" :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
        </td>
      </tr>
      <tr>
        <td>
          <el-form-item label="职位:">
            <el-select v-model="form.zhiWeir" placeholder="请选择职位" clearable>
              <el-option v-for="item in opp" :key="item.id" :label="item.postsName" :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
        </td>
      </tr>
      <tr>
        <td>
          <el-form-item label="员工姓名:">
            <el-select v-model="form.name" placeholder="请选择职位" clearable>
              <el-option v-for="item in aa" :key="item.id" :label="item.yuanGongName" :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
        </td>
      </tr>

      <tr>
        <td>
          <el-form-item label="上级负责人:" prop="ren">
            <el-select v-model="form.ren" placeholder="请选择学历" clearable>
              <el-option v-for="item in bb" :key="item.id" :label="item.headName" :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
        </td>
      </tr>
      <tr>
        <td>
          <el-form-item label="入职日期">
            <el-col :span="11">
              <el-date-picker type="date" placeholder="选择出生年月" v-model="form.ruDate" style="width: 100%;">
              </el-date-picker>
            </el-col>
          </el-form-item>
        </td>
      </tr>
      <tr>
        <td>
          <el-form-item label="备注:">
            <el-input v-model="form.beiZhu" placeholder="请输入邮箱"></el-input>
          </el-form-item>
        </td>
      </tr>
      <el-form-item>
        <el-button type="primary" @click="Update">提交</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
export default {
  data () {
    return {
      form: {
        buMne: '',
        zhiWeir: '',
        name: '',
        ren: '',
        ruDate: '',
        beiZhu: '',
      },
      aa: [],
      bb: [],
      options: [],
      opp: [],
    }
  },
  created () {
    this.BingName();
    this.BingBu();
    this.BingZhi();
    this.BingShang();
    this.Tian();
  },
  methods: {
    Tian () {
      var ids = localStorage.getItem("kqxq");
      this.$http({
        url: 'https://localhost:44357/api/Emp/OnbFan',
        method: "get",
        params: {
          id: ids
        }
      }).then((r) => {
        this.form = r.data
      })
    },
    Update () {
      this.$http({
        url: "https://localhost:44357/api/Emp/OnbUpdate",
        method: "post",
        data: this.form
      }).then((r) => {
        if (r.data = 200) {
          this.$message({
            message: '恭喜你，员工入职修改成功！',
            type: 'success'
          });
          this.$router.push("/OnbSel");
        }
      })
    },
    BingBu () {
      this.$http({
        url: "https://localhost:44357/api/Emp/BingBu",
        method: "get",
      }).then((r) => {
        this.options = r.data;
      })
    },
    BingZhi () {
      this.$http({
        url: "https://localhost:44357/api/Emp/BingZhi",
        method: "get",
      }).then((r) => {
        this.opp = r.data;
      })
    },
    BingName () {
      this.$http({
        url: "https://localhost:44357/api/Emp/BingName",
        method: "get",
      }).then((r) => {
        this.aa = r.data;
      })
    },
    BingShang () {
      this.$http({
        url: "https://localhost:44357/api/Emp/BingShang",
        method: "get",
      }).then((r) => {
        this.bb = r.data;
      })
    },
    onSubmit () {
      console.log('submit!');
    }
  }
}
</script>